/* ==================== 全局样式 ==================== */
:root {
  --primary-color: #2c3e50;
  --accent-color: #e74c3c;
  --btn-bg: #3498db;
  --btn-hover: #2980b9;
  --correct-bg: #2ecc71;
  --wrong-bg: #e74c3c;
  --input-border: #bdc3c7;
  --card-bg: #ffffff;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

/* 通用样式 */
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f9f9f9;
}

/* 导航栏 */
.navbar {
  background-color: var(--primary-color);
  color: white;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.navbar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.navbar-left,
.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-title {
  font-size: 24px;
  font-weight: bold;
}

.timer {
  font-size: 20px;
  font-weight: bold;
  background-color: #34495e;
  padding: 5px 15px;
  border-radius: 5px;
}

.navbar-btn {
  padding: 0.8rem 1.5rem;
  border-radius: 6px;
  background: #3498db;
  color: white;
  transition: all 0.3s ease;
}

.navbar-btn:hover {
  background: #2980b9;
}

.navbar-tip {
  font-size: 0.9rem;
  color: #7f8c8d;
  margin-right: 1rem;
}

/* 主内容 */
.container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 2rem;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.header {
  text-align: center;
  margin-bottom: 2rem;
}

.title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.btn {
  padding: 0.8rem 2rem;
  border: none;
  border-radius: 8px;
  background: var(--btn-bg);
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover {
  background: var(--btn-hover);
  transform: translateY(-2px);
}

/* ==================== 题目网格样式 ==================== */
.question-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 每行 4 个 */
  gap: 1.5rem;
  padding: 1rem;
}

.question-row {
  display: contents; /* 确保每行正确排列 */
}

.question-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  transition: border-color 0.3s ease;
  border: 2px solid transparent;
}

.question-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.question-item.focused {
  border-color: #3498db;
  box-shadow: 0 0 8px rgba(52, 152, 219, 0.3);
}

.number {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
  min-width: 30px;
  text-align: center;
}

.operator {
  color: var(--accent-color);
  font-weight: 700;
  font-size: 1.6rem;
}

.answer-input {
  width: 80px;
  height: 40px;
  border: 2px solid var(--input-border);
  border-radius: 6px;
  text-align: center;
  font-size: 1.2rem;
  transition: var(--transition);
}

.answer-input:focus {
  border-color: var(--btn-bg);
  box-shadow: 0 0 8px rgba(52, 152, 219, 0.3);
  outline: none;
  transform: scale(1.05);
}

/* ==================== 正确/错误状态样式 ==================== */
.correct {
  background: var(--correct-bg) !important;
  color: white !important;
  border-color: transparent !important;
}

.wrong {
  background: var(--wrong-bg) !important;
  color: white !important;
  border-color: transparent !important;
}

.current-focus {
  border-color: var(--accent-color) !important;
  background: #fff9f9;
}

/* 注册模态框增强样式 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  position: relative;
  margin: 15% auto;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  color: var(--primary-color);
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}

.modal .form-group {
  margin-bottom: 15px;
}

.modal .form-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--primary-color);
  font-weight: 500;
}

.modal .form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.modal .form-control:focus {
  border-color: var(--btn-bg);
  outline: none;
  box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

.modal .btn-primary {
  width: 100%;
  padding: 10px;
  background-color: var(--btn-bg);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
}

.modal .btn-primary:hover {
  background-color: var(--btn-hover);
}

/* 模态框样式 */
.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1001;
}

.modal-content {
  background-color: var(--card-bg);
  padding: 2rem;
  border-radius: 12px;
  width: 350px;
  text-align: center;
  box-shadow: var(--shadow);
}

.modal-content h2 {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
}

.modal-content input {
  width: 100%;
  padding: 0.8rem;
  margin-bottom: 1rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  font-size: 1rem;
  transition: var(--transition);
}

.modal-content input:focus {
  border-color: var(--btn-bg);
  box-shadow: 0 0 8px rgba(52, 152, 219, 0.3);
  outline: none;
}

.modal-content button {
  padding: 0.8rem 1.5rem;
  background-color: var(--btn-bg);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  margin-right: 0.5rem;
}

.modal-content button:hover {
  background-color: var(--btn-hover);
  transform: translateY(-2px);
}

.modal-content .switch-mode {
  color: var(--btn-bg);
  cursor: pointer;
  text-decoration: underline;
  font-size: 0.9rem;
  margin-top: 1rem;
}

.submitting {
  transform: scale(0.95);
  opacity: 0.8;
  transition: all 0.2s ease;
}

/* ==================== 响应式布局 ==================== */
@media (max-width: 992px) {
  .question-grid {
    grid-template-columns: repeat(2, 1fr); /* 小屏幕每行 2 个 */
  }
}

@media (max-width: 768px) {
  .navbar-right {
    flex-direction: column;
    gap: 0.5rem;
  }

  .question-grid {
    grid-template-columns: 1fr; /* 超小屏幕每行 1 个 */
  }

  .question-item {
    justify-content: center;
  }

  .btn {
    width: 100%;
  }

  .modal-content {
    width: 90%;
    padding: 1.5rem;
  }
}

@media (max-width: 576px) {
  .container {
    padding: 1rem;
  }

  .title {
    font-size: 2rem;
  }

  .timer {
    font-size: 1.5rem;
  }
}

/* 用户中心统计卡片 */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.stat-item {
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease;
}

.stat-item:hover {
  transform: translateY(-3px);
}

.stat-item h3 {
  color: #2c3e50;
  margin: 0 0 0.8rem;
  font-size: 1.1rem;
}

.stat-item p {
  font-size: 1.8rem;
  color: #e74c3c;
  font-weight: 600;
  margin: 0;
}

/* 表格优化 */
.history-table {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.history-table table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th {
  background-color: #f8f9fa;
  padding: 1rem;
  font-weight: 500;
}

.history-table td {
  padding: 1rem;
  border-bottom: 1px solid #f0f0f0;
}

.history-table tr:last-child td {
  border-bottom: none;
}

/* 删除侧边栏样式 */
.sidebar, .nav-btn { display: none !important; }

.main-content {
  margin-left: 0;
  padding: 2rem;
}